import httpx


class HttpRequester:
    __instance = None

    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance = object.__new__(cls)
        return cls.__instance

    def __init__(self):
        self.client = httpx.AsyncClient()

    async def get(self, url, params, header=None):
        return await self.client.get(url, params=params, headers=header)

    async def post(self, url, body, header=None, using_json=True):
        if using_json:
            return await self.client.post(url, json=body, headers=header)
        else:
            return await self.client.post(url, data=body, headers=header)
